package com.tuananh.radnom.model;

import java.io.Serializable;
import java.util.HashMap;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "ne")
public abstract class NetElement implements NeValidator, Assignable,Serializable {
	/**
	 * This is the unique identifier for an network element,
	 * cannot be changed
	 */
	String name;
	/**
	 * This name can be change, default is {@link #name}
	 */
	String displayName;
	
	
	String descript;


	@XmlAttribute(required=false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@XmlAttribute(name="display-name",required=false)
	public String getDisplayName() {
		return this.displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	@XmlAttribute(required=false)
	public String getDescript() {
		return descript;
	}

	public void setDescript(String descript) {
		this.descript = descript;
	}

	public boolean assign(Object obj) {
		// TODO Auto-generated method stub
		try {
			NetElement ne = (NetElement) obj;
			NetElement temp = new NetElement() {

				public boolean validate(Object ne) {
					// TODO Auto-generated method stub
					return false;
				}
			};
			if (ne.name != null)
				temp.name = ne.getName();
			if (ne.getDescript() != null)
				temp.descript = ne.getDescript();
			
			//
			this.name=temp.name;
			this.descript=temp.descript;
		} catch (Exception e) {

		}
		return false;
	}
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if (obj instanceof NetElement){
			if (((NetElement)obj).getName().equals(this.getName()))
				return true;
		}
		return false;
	}
}
